package com.yue.listener;

import com.yue.domain.User;
import com.yue.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Random;

@Component
public class AppStartListener implements ApplicationRunner {
    @Autowired
    private UserService userService;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("插入开始时间:"+ LocalDateTime.now());
        /*Random random = new Random();
        for(int i=0;i<1000000;i++){
            User user = new User();
            user.setName("小明"+i);
            user.setAge(random.nextInt(100));
            userService.addUser(user);
        }*/
        System.out.println("插入结束时间:"+ LocalDateTime.now());
    }
}
